From: Jonas Dreßler Date: Sun, 13 Jul 2025 10:01:10 +0000 (+0200) Subject: switcherPopup: Move to a ClutterGesture for closing the popup X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~104^2^2~30 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=314137c8c;p=gnome-shell.git switcherPopup: Move to a ClutterGesture for closing the popup When the user presses a mouse button outside of the switcherPopup, the popup should close. This broke when we moved StButton to ClutterGesture, because the button_press_event() handler in switcherPopup will close the popup before the click gesture recognizes. Since we're trying to move away from direct event handling anyway, port this functionality to a LongPressGesture with a duration of 0, so that the popup closes immediately on button press as it used to. Part-of: --- diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js index 3af9188a5..790ac091e 100644 --- a/js/ui/switcherPopup.js +++ b/js/ui/switcherPopup.js @@ -68,6 +68,22 @@ export const SwitcherPopup = GObject.registerClass({ coordinate: Clutter.BindCoordinate.ALL, })); + const longPressGesture = new Clutter.LongPressGesture({ + long_press_duration_ms: 0, + }); + longPressGesture.connect('may-recognize', () => { + const coords = longPressGesture.get_coords_abs(); + const actorAtCoords = + global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, coords.x, coords.y); + + return !this._switcherList?.contains(actorAtCoords); + }); + longPressGesture.connect('recognize', () => { + // User clicked outside + this.fadeAndDestroy(); + }); + this.add_action(longPressGesture); + // Initially disable hover so we ignore the enter-event if // the switcher appears underneath the current pointer location this._disableHover(); @@ -223,12 +239,6 @@ export const SwitcherPopup = GObject.registerClass({ return Clutter.EVENT_STOP; } - vfunc_button_press_event() { - /* We clicked outside */ - this.fadeAndDestroy(); - return Clutter.EVENT_PROPAGATE; - } - _scrollHandler(direction) { if (direction === Clutter.ScrollDirection.UP) this._select(this._previous());